In [128]:
%run /home/grg/git/alfa/nilearn-helper.py
import nibabel as nib
import os.path as osp
import sys
%matplotlib inline
sys.path.append('/home/grg/git/alfa/')
import multireg_spm12 as mreg

Difference between clusters using or not FreeSurfer ventricles in the model


In [140]:
thresholded_map1, threshold1 = map_threshold('/home/grg/spm/analysis/MD_w_FS_ventvol/estimatecontrasts/spmT_0006.nii', threshold=0.001, cluster_threshold=50)
thresholded_map2, threshold2 = map_threshold('/home/grg/spm/analysis/MD_wo_ventvol/estimatecontrasts/spmT_0006.nii', threshold=0.001, cluster_threshold=50)

plot_two_maps(thresholded_map2, threshold=threshold2, start=-32, end= 36, step=2, row_l=8, overlay=[thresholded_map1],
             title='Difference between clusters using or not FreeSurfer ventricles in the model (green:wo/red:w)')


Saving to... /tmp/tmpA69CCZ.png

In [ ]:
i=6
paramtype = 'MD_corr'
analysis_name='%s_w_FS_ventvol'%paramtype
analysis_wd = osp.join('/home/grg/spm/analysis', analysis_name)
spm = glob(osp.join(analysis_wd, 'estimatecontrasts/SPM.mat'))
aal_fp = '/usr/local/MATLAB/R2014a/toolbox/spm12/toolbox/aal/ROI_MNI_V5.nii'
mask_fp = '/home/grg/spm/MNI_T1_brain_mask.nii'
excel_fp = '/home/grg/spm/designmatrix3.xls'
print 'Found SPM files:', spm
print 'Reading', excel_fp, 'looking up column', paramtype, '...'
a = mreg.original_version(paramtype, excel_fp, analysis_wd, mask_fp, analysis_name)
n1 = a.get_node('modeldesign')
n3 = a.get_node('estimatecontrasts')
print '# of scans included in the analysis:', len(n1.inputs.in_files)

img = osp.join(analysis_wd, 'estimatecontrasts/spmT_00%02d.nii'%i)
print img
contrast_name = n3.inputs.contrasts[i-1][0]
thresholded_map1, threshold1 = map_threshold(img, threshold=0.001, cluster_threshold=0)

In [130]:
plot_stat_map(thresholded_map1, threshold=threshold1, row_l=6, start=-22, end=34, step=2,
              title= '(%s) %s - T>%.02f - p<0.001 (uncor.)'%(paramtype, contrast_name, threshold1))


Saving to... /tmp/tmpe9CQZW.png

Difference between clusters using or not Juando's ventricles in the model


In [150]:
map1 = '/home/grg/spm/analysis/MD_w_JDG_ventvol/estimatecontrasts/spmT_0006.nii'
map2 = '/home/grg/spm/analysis/MD_wo_ventvol/estimatecontrasts/spmT_0006.nii'
thresholded_map1, threshold1 = map_threshold(map1, threshold=0.001, cluster_threshold=50)
thresholded_map2, threshold2 = map_threshold(map2, threshold=0.001, cluster_threshold=50)

plot_two_maps(thresholded_map1, threshold=threshold2, start=-36, end= 32, step=2, row_l=8, overlay=[thresholded_map2],
                  title= 'Difference map after introducing Juando\'s ventricular volumes in the model (green:w - red:wo)\n (%s) %s - T>%.02f - p<0.001 (uncor.)'
              %(paramtype, contrast_name, threshold1))


Saving to... /tmp/tmpbYjAbd.png

In [151]:
map1 = '/home/grg/spm/analysis/MD_wo_ventvol/estimatecontrasts/spmT_0006.nii'
map2 = '/home/grg/spm/analysis/MD_corr_wo_ventvol/estimatecontrasts/spmT_0006.nii'
thresholded_map1, threshold1 = map_threshold(map1, threshold=0.001, cluster_threshold=50)
thresholded_map2, threshold2 = map_threshold(map2, threshold=0.001, cluster_threshold=50)

plot_two_maps(thresholded_map1, threshold=threshold2, start=-36, end= 32, step=2, row_l=8, overlay=[thresholded_map2],
                  title= 'Difference map after correction of MD maps (green:wo - red:w) without ventricles\n (%s) %s - T>%.02f - p<0.001 (uncor.)'
              %(paramtype, contrast_name, threshold1))


Saving to... /tmp/tmpBd4FZ1.png

In [153]:
map1 = '/home/grg/spm/analysis/MD_wo_ventvol/estimatecontrasts/spmT_0006.nii'
map2 = '/home/grg/spm/analysis/MD_corr_w_FS_ventvol/estimatecontrasts/spmT_0006.nii'
thresholded_map1, threshold1 = map_threshold(map1, threshold=0.001, cluster_threshold=50)
thresholded_map2, threshold2 = map_threshold(map2, threshold=0.001, cluster_threshold=50)

plot_two_maps(thresholded_map1, threshold=threshold2, start=-36, end= 32, step=2, row_l=8, overlay=[thresholded_map2],
                  title= 'Difference map raw MD no ventricle (g) / corr MD + FS ventricles (r)\n (%s) %s - T>%.02f - p<0.001 (uncor.)'
              %(paramtype, contrast_name, threshold1))


Saving to... /tmp/tmpuiCBqw.png

In [ ]:
map1 = '/home/grg/spm/analysis/MD_wo_ventvol/estimatecontrasts/spmT_0006.nii'
map2 = '/home/grg/spm/analysis/MD_corr_w_JDG_ventvol/estimatecontrasts/spmT_0006.nii'
thresholded_map1, threshold1 = map_threshold(map1, threshold=0.001, cluster_threshold=50)
thresholded_map2, threshold2 = map_threshold(map2, threshold=0.001, cluster_threshold=50)

plot_two_maps(thresholded_map1, threshold=threshold2, start=-36, end= 32, step=2, row_l=8, overlay=[thresholded_map2],
                  title= 'Difference map raw MD no ventricle (g) / corr MD + FS ventricles (r)\n (%s) %s - T>%.02f - p<0.001 (uncor.)'
              %(paramtype, contrast_name, threshold1))